package net.tngou.boot.controller;



import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import net.tngou.boot.lucene.TngouDBHelp;
import net.tngou.boot.lucene.Field;
import net.tngou.boot.lucene.Field.Type;
import net.tngou.boot.lucene.Page;
/**
 * 消息操作
 * @author tngou@tngou.net
 *
 */
@RestController
@RequestMapping("/serach/") 
public class SearchController extends BaseController {
	TngouDBHelp TngouDBHelp  = new TngouDBHelp();
	
	@RequestMapping(value = "/")
	public List<String> execute(@RequestParam("keyword") String keyword) {
		String tableName="company";
		Field name= new Field("name",keyword, Type.Text);
//		Field person= new Field("person", keyword, Type.Text);
		Page page = TngouDBHelp.select(tableName, 1, 10, name);
		List<Map<String, Object>> list = page.getList();
		List<String> ls = new ArrayList<>();
		list.forEach(e->{
			ls.add(e.get("name").toString());
		});
		return ls;
	}
}
